package com.hnkywl.sts.service.sfgl;

import com.hnkywl.sts.dao.sfgl.FkshmxDao;
import com.hnkywl.sts.entity.sfgl.Sfkmx;
import com.hnkywl.sts.util.BaseUtils;
import net.ruixin.orm.hibernate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 说明：
 * 包:        com.hnkywl.sts.service.sfgl
 * 类描述:   付款审核服务类
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Service
public class FkshmxService {
   private FkshmxDao fkshmxDao;

    @Transactional
    public String findAllFkshmx(Long fkshId,int pageNo, int pageSize) {
        Page<Sfkmx> fkshmxPage = this.fkshmxDao.findFkshmxList(fkshId,pageNo, pageSize);
        List<Sfkmx> fkshmxList = fkshmxPage.getResult() == null ? new ArrayList<Sfkmx>() : fkshmxPage.getResult();
        String fkshmxJson = BaseUtils.fetchCollectionToJson(".",false,fkshmxList, "id","fksh.bm","fkrq","bcfkmx","jkd.id","jkd.jkdbm","jkd.gys.id","jkd.gys.qc","jkd.zfkx","jkd.zfje","jkd.yfje","jkd.zffs.z","jkd.zffs.id","jkd.zfsj","jkd.version");
        return "{\"total\":" + fkshmxPage.getTotalCount() + ",\"rows\":[" + fkshmxJson + "]}";
    }

    @Transactional
    public String findAllFkshmxByJkd(Long jkdId,int pageNo, int pageSize) {
        Page<Sfkmx> fkshmxPage = this.fkshmxDao.findAllFkshmxByJkd(jkdId,pageNo, pageSize);
        List<Sfkmx> fkshmxList = fkshmxPage.getResult() == null ? new ArrayList<Sfkmx>() : fkshmxPage.getResult();
        String fkshmxJson = BaseUtils.fetchCollectionToJson(fkshmxList, "id","fksh.bm","fkrq","bcfkmx","jkd.id","jkd.jkdbm","jkd.gys.id","jkd.gys.qc","jkd.zfkx","jkd.zfje","jkd.yfje","jkd.zffs.z","jkd.zffs.id","jkd.zfsj");
        return "{\"total\":" + fkshmxPage.getTotalCount() + ",\"rows\":[" + fkshmxJson + "]}";
    }

    @Autowired
    public void setFkshmxDao(FkshmxDao fkshmxDao) {
        this.fkshmxDao = fkshmxDao;
    }
}
